{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="demo"></table>
                    
                    <!--操作模板-->
                    <script type="text/html" id="opeBar">
                    	<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
  						<!-- <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a> -->
                        <!-- {{# if(d.par_status == 1){ }}
                        <a href="javascript:;" onclick="wk.href('{:url('partnerAdd')}?id={{d.par_id}}')" class="btn btn-primary btn-xs m-r-xs" >绑定</a>
                        <a href="javascript:;" onclick="wk.confirm('{{d.par_id}}','{:url('partnerDel')}')" class="btn btn-danger btn-xs m-r-xs" >删除</a>
                        {{# } }}
                        {{# if(d.par_status == 2){ }}
                        <a href="javascript:;" onclick="wk.href('{:url('money')}?id={{d.user_id}}')" class="btn btn-primary btn-xs m-r-xs" >查看收益</a>
                        <a href="javascript:;" onclick="wk.href('{:url('partneredit')}?id={{d.par_id}}')" class="btn btn-primary btn-xs m-r-xs" >解绑</a>
                        {{# } }}
                        <a href="javascript:;" onclick="son({{d.par_id}})" class="btn btn-primary btn-xs m-r-xs" >排序</a> -->
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
            , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("partners/classindex")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
                {type:'numbers', width: 80, title: '序号'}
                , {field: 'class_name', width: '', title: '合伙人名称', align: 'center'}
                , {field: 'class_money', width: '', title: '成为合伙人金额', align: 'center'}
                , {field: 'class_jifen', width: '', title: '奖励积分数', align: 'center'}
                , {field: 'class_edit_time', width: '', title: '修改时间', align: 'center'}
                , {fixed: 'right', width: 300, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
        });

        form.verify({
            percent: [
                /^[1-9]\d*$/
                ,'非零正整数'
            ]
        });

        //监控页面追加的 修改删除
		table.on('tool(demo)', function(obj){
			var data = obj.data;
		 switch(obj.event){
		    case 'edit':
		     //  	var sonlist =  layer.open({
			    //     type:2,
			    //     area:['1000px','400px'],
			    //     fixed:false,
			    //     maxmin:true,
			    //     content:"/index.php/user/Partnerad/classadd/id/"+id+"/c_id/"+data.id,
			    // })
                location.href = "{:url('admin/Partners/classedit')}?class_id="+data.class_id;

		    break;
		  };
		});
    });
    function son(shop_id) {
        layer.prompt({
            formType: 2,
            title: '修改排序值',
            area: ['200px', '50px'],
            btn: ['确认', '取消'],
            maxlength:11,
        },function(value, index, elem){
            var pattern = /^[1-9]\d*$/;
            if(!pattern.test(value)){
                wk.error('请填写正确的排序值');
                return;
            }
            send1(shop_id,value);
            layer.close(index);
        });
    }
    function send1(shop_id,value){
        $.ajax({
            url: "{:url('addSort')}",
            type: "post",
            dataType: "json",
            data: {id:shop_id,num:value},
            success: function (res) {
                if(res.code == 200){
                    layer.msg(res.msg,{icon:1,time:1500,shade: 0.1},function(){
                        //重载当前页表格
                        $(".layui-laypage-btn").click();
                    });
                } else if (res.code == 100){
                    layer.msg(res.msg,{icon:2,time:1500,shade: 0.1});
                }
            }
        });
    }
</script>
</body>
</html>